const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: {
    main: './src/main.js',
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    publicPath: '/',
    filename: 'js/vue.min.js',
  },
  module: {
    rules: [
      {
        test: /(\.jsx|\.js)$/,
        use: {
            loader: "babel-loader"
        },
        exclude: /node_modules/
      },
    ],
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: "index.html",
      template: './index.html',
      minify: true,
      inject: 'body',
      minify: {
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
      },
      hash: true,
    }),
  ],
  devServer: {
    contentBase: path.join(__dirname, "dist/"),
    historyApiFallback: true,
    host: 'localhost',
    open: true,
    inline: true,
    port: 8000,
    compress: true,//服务器返回给浏览器的时候是否启动gzip压缩
  },
};